---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Unconditional/Severity/PredictedValues.log
  log type:  text
 opened on:  12 Nov 2016, 22:23:21

. cd "/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Unconditional/Severity";
/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Unconditional/Severity

. **************************************************************;
. *Author: Jeff Carter                                         *;
. *Date: Saturday, May 23, 2015                              *;
. *Purpose: Simulating Predictions                *;
. **************************************************************;
. ** Need Legend for Probabilities and Differences  **;
. use "/Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Unconditional/Severity/SimData.dta";

. postutil clear;

. postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2 prob_hat3 lo3 hi3 prob_hat4 lo4 hi4 prob_hat5 lo5 h
> i5
>                 diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1 diff_hat2 diff_lo2 diff_hi2 
>                 using PredictedValues, replace;
(note: file PredictedValues.dta not found)

. noisily display "start";
start

. local a=0 ;

. while `a' < .1 { ;
  2. {;
  3. scalar h_Accountable =   0  ;
  4. scalar h_LameDuck= 1  ;
  5. scalar h_Civilian = 0;
  6. scalar h_Military = 1;
  7. scalar h_Constant = 1;
  8. scalar h_Parliament = 0;
  9. scalar h_CivilWar = 0;
 10. scalar h_GDPpc =  12589.35;
 11. scalar h_Growth = 3.453132;
 12. scalar h_MajorPower = 0;
 13. scalar h_Borders = 2;
 14. scalar h_Mobilization =  -.0008714 ;
 15. scalar h_Time = 5;
 16.  scalar h_Rivalry = 0;
 17. scalar h_Female = 0;
 18. generate x_betahat0 = MG_b1*h_Accountable
>     + MG_b2*h_Civilian
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3);
 19. generate x_betahat1 = MG_b1* h_LameDuck
>     + MG_b2*h_Civilian
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3);
 20. gen prob0=  1/(1+exp(x_betahat0-MG_b10));
 21. gen prob1=   (1/(1+exp(x_betahat0-MG_b11)))  -  (1/(1+exp(x_betahat0-MG_b10)))  ;
 22. gen prob2=   1- (1/(1+exp(x_betahat0-MG_b11)));
 23. gen prob3=  1/(1+exp(x_betahat1-MG_b10));
 24. gen prob4=  (1/(1+exp(x_betahat1-MG_b11)))  -  (1/(1+exp(x_betahat1-MG_b10)))  ;
 25. gen prob5=   1- (1/(1+exp(x_betahat1-MG_b11)));
 26.         gen diff0=prob3-prob0 ;
 27. gen diff1=prob4-prob1 ;
 28. gen diff2=prob5-prob2 ;
 29.         egen probhat0=mean(prob0) ;
 30. egen probhat1=mean(prob1) ;
 31. egen probhat2=mean(prob2) ;
 32. egen probhat3=mean(prob3) ;
 33. egen probhat4=mean(prob4) ;
 34. egen probhat5=mean(prob5) ;
 35. egen diffhat0=mean(diff0) ;
 36. egen diffhat1=mean(diff1) ;
 37. egen diffhat2=mean(diff2) ;
 38. tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2 prob_hat3 lo3 hi3 prob_hat4 lo4 hi4 prob_hat5 lo5 hi5
>         diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1 diff_hat2 diff_lo2 diff_hi2;
 39.             _pctile prob0, p(2.5,97.5) ;
 40.     scalar `lo0'=r(r1) ;
 41.     scalar `hi0'=r(r2) ;
 42.     _pctile prob1, p(2.5,97.5) ;
 43.     scalar `lo1'=r(r1) ;
 44.     scalar `hi1'=r(r2) ;
 45.     _pctile prob2, p(2.5,97.5) ;
 46.     scalar `lo2'=r(r1) ;
 47.     scalar `hi2'=r(r2) ;
 48.     _pctile prob3, p(2.5,97.5) ;
 49.     scalar `lo3'=r(r1) ;
 50.     scalar `hi3'=r(r2) ;
 51.     _pctile prob4, p(2.5,97.5) ;
 52.     scalar `lo4'=r(r1) ;
 53.     scalar `hi4'=r(r2) ;
 54.     _pctile prob5, p(2.5,97.5) ;
 55.     scalar `lo5'=r(r1) ;
 56.     scalar `hi5'=r(r2) ;
 57.             _pctile diff0, p(2.5,97.5) ;
 58.     scalar `diff_lo0'= r(r1) ;
 59.     scalar `diff_hi0'=r(r2) ;
 60.     _pctile diff1, p(2.5,97.5) ;
 61.     scalar `diff_lo1'= r(r1) ;
 62.     scalar `diff_hi1'=r(r2) ;
 63.     _pctile diff2, p(2.5,97.5) ;
 64.     scalar `diff_lo2'= r(r1) ;
 65.     scalar `diff_hi2'=r(r2) ;
 66.             scalar `prob_hat0'=probhat0 ;
 67.     scalar `prob_hat1'=probhat1 ;
 68.     scalar `prob_hat2'=probhat2 ;
 69.     scalar `prob_hat3'=probhat3 ;
 70.     scalar `prob_hat4'=probhat4 ;
 71.     scalar `prob_hat5'=probhat5 ;
 72.           scalar `diff_hat0'=diffhat0 ;
 73.     scalar `diff_hat1'=diffhat1 ;
 74.     scalar `diff_hat2'=diffhat2 ;
 75.  post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`prob_hat2') (`lo2') (`hi2')
>         (`prob_hat3') (`lo3') (`hi3') (`prob_hat4') (`lo4') (`hi4') (`prob_hat5') (`lo5') (`hi5')
>         (`diff_hat0') (`diff_lo0') (`diff_hi0') (`diff_hat1') (`diff_lo1') (`diff_hi1') (`diff_hat2') (`diff_lo2') (`diff
> _hi2')
> 
> 
>     ;
 76.     } ;
 77. drop    x_betahat0 x_betahat1
>         prob0 prob1 prob2 prob3 prob4 prob5
>         diff0 diff1 diff2
>         probhat0 probhat1 probhat2 probhat3 probhat4 probhat5
>         diffhat0 diffhat1 diffhat2;
 78.     local a=`a'+ .1 ;
 79.     display "." _c ;
 80.     } ;
.
. display "" ;


.  postclose mypost ;

. use PredictedValues, clear;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         1    .9514751           .   .9514751   .9514751
         lo0 |         1    .9309019           .   .9309019   .9309019
         hi0 |         1    .9675115           .   .9675115   .9675115
   prob_hat1 |         1    .0375823           .   .0375823   .0375823
         lo1 |         1    .0249395           .   .0249395   .0249395
-------------+--------------------------------------------------------
         hi1 |         1    .0536323           .   .0536323   .0536323
   prob_hat2 |         1    .0109425           .   .0109425   .0109425
         lo2 |         1    .0069468           .   .0069468   .0069468
         hi2 |         1    .0163456           .   .0163456   .0163456
   prob_hat3 |         1    .9740989           .   .9740989   .9740989
-------------+--------------------------------------------------------
         lo3 |         1    .9608153           .   .9608153   .9608153
         hi3 |         1    .9838017           .   .9838017   .9838017
   prob_hat4 |         1    .0201652           .   .0201652   .0201652
         lo4 |         1    .0125851           .   .0125851   .0125851
         hi4 |         1    .0308094           .   .0308094   .0308094
-------------+--------------------------------------------------------
   prob_hat5 |         1    .0057359           .   .0057359   .0057359
         lo5 |         1    .0034104           .   .0034104   .0034104
         hi5 |         1    .0089909           .   .0089909   .0089909
   diff_hat0 |         1    .0226238           .   .0226238   .0226238
    diff_lo0 |         1     .007232           .    .007232    .007232
-------------+--------------------------------------------------------
    diff_hi0 |         1    .0406117           .   .0406117   .0406117
   diff_hat1 |         1   -.0174171           .  -.0174171  -.0174171
    diff_lo1 |         1   -.0313291           .  -.0313291  -.0313291
    diff_hi1 |         1   -.0055669           .  -.0055669  -.0055669
   diff_hat2 |         1   -.0052066           .  -.0052066  -.0052066
-------------+--------------------------------------------------------
    diff_lo2 |         1   -.0096718           .  -.0096718  -.0096718
    diff_hi2 |         1   -.0016595           .  -.0016595  -.0016595

. saveold PredictedValues, replace;
file PredictedValues.dta saved

. log close;
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/Military/Unconditional/Severity/PredictedValues.log
  log type:  text
 closed on:  12 Nov 2016, 22:23:21
---------------------------------------------------------------------------------------------------------------------------
